package com.zhiyou100.crm.util;

import com.zhiyou100.crm.pojo.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class S_session {
    static  SqlSession sqlSession=null;
    public static  SqlSession getSession() throws IOException {
        InputStream resourceAsStream= Resources.getResourceAsStream("mybatis-cfg.xml");
        SqlSessionFactory factory= new SqlSessionFactoryBuilder().build(resourceAsStream);
        sqlSession= factory.openSession();
        return sqlSession;
    }
    public  static void submit(){
        sqlSession.commit();
    }
}
